Semantic Web Technologies: XML, RDF, OWL
This talk summarizes material from the appropriate RFCs and W3C
Recommendations, as well as:
- Extensible Markup
Language (XML) 1.0 [1] W3C Recommendation, 2006
- Michel Klein. Tutorial: The
Semantic Web. [2] IEEE Intelligent
Systems,(16)2. 2001.
- Stefan Decker, Sergey Melnik, Frank Van
Harmelen, Dieter Fensel, Michel Klein, Jeen Broekstra, Michael
Erdmann, and Ian Horrocks. The Semantic
Web: The Roles of XML and RDF. [3] IEEE Internet
Computing,(4)5. 2000.
- Edd Dumbill Finding
friends with XML and RDF [4]: The Friend-of-a-Friend
vocabulary can make it easier to manage online communities,
2002
- Philip McCarthy Search
RDF Data with SPARQL [5]: SPARQL and the Jena Toolkit open up
the semantic Web, 2005.
- Deborah L. McGuinness and Frank van
Harmelen editors, OWL Web Ontology
Language Overview [6]
1 XML
- eXtensible Markup Language. Defined in the W3C Recommendation
6 [7], now over 10
years old [8].
- extensible means that it only provides a data format,
not an actual vocabulary. XML is a metalanguage.
- Markup means that certain sequences of characters
contain information indicating the role of the content.
- tags are those words between pointy brackets:
<tag>
1.1 XML
1.2 XML
- Comments are delimited between
<!--
and
-->
- Processing instructions allow a document to contain
instructions to applications. The are of the form
<?
Instructions ?>
.
- CDATA sections are used to escape characters that would
otherwise be considered XML markup. They are of the form
<![CDATA[ datahere ]]>
- If you just want to escape a character it is better to use
the character entities,
- All documents must begin with an XML declaration like
<?xml version="1.0"?>
1.3 XML Example
- An example purchase order:
<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<state>CA</state>
<zip>90952</zip>
</shipTo>
<billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Old Town</city>
<state>PA</state>
<zip>95819</zip>
</billTo>
<comment>Hurry, my lawn is going wild!</comment>
<items>
<item partNum="872-AA">
<productName>Lawnmower</productName>
<quantity>1</quantity>
<USPrice>148.95</USPrice>
<comment>Confirm this is electric</comment>
</item>
<item partNum="926-AA">
<productName>Baby Monitor</productName>
<quantity>1</quantity>
<USPrice>39.98</USPrice>
<shipDate>1999-05-21</shipDate>
</item>
</items>
</purchaseOrder>
2 Document Type Definitions
3 XML Namespaces
- Defined in the XML
namespaces recommendation [9]
- An XML namespace is a collection of names, identified
by a URI reference (RFC2396 [10]), which
are used in XML documents as element types and attribute
names.
- You use them when you need to use more than one DTD or
Schema.
- A namespace is declared as using the
xmlns
attribute:
<x xmlns="http://www.w3.org/TR/REC-html40"
xmlns:edi="http://ecommerce.org/schema">
<edi:price units="Euro">32</edi:price>
<lineItem edi:taxClass="exempt">Baby food</lineItem>
</x>
- The
edi
is called the namespace prefix.
- After this declaration and within the
x
element
any tag tagname
that is appears as
edi:tagname
will be considered part of the
edi
schema.
- If the prefix is missing then that namespace becomes the
default namespace.
- Namespace scopes are nested:
<?xml version="1.0"?>
<book xmlns="urn:loc.gov:books"
xmlns:isbn="urn:ISBN:0-395-36341-6">
<title>Cheaper by the Dozen</title>
<isbn:number>1568491379</isbn:number>
<notes>
<p xmlns="urn:w3-org-ns:HTML">
This is a <i>funny</i> book!
</p>
</notes>
</book>
4 XML Schema
- XML Schema [11] is the successor to DTDs.
- It provides a richer grammar for prescribing the structure
of elements.
- For example, you can specify the exact number of allowed
occurrences of child elements, or specify default
values.
- They provide data typing.
- They provide inclusion and derivation mechanisms. Reuse
common elements.
- They are written in XML. The structures of XML Schema are
themselves described using an XML Schema.
- The following is the schema definition for our PurchaseOrder
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Purchase order schema for Example.com.
Copyright 2000 Example.com. All rights reserved.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress" />
<xsd:element name="billTo" type="USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:decimal"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
</xsd:complexType>
<xsd:complexType name="Items">
<xsd:sequence>
<xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity">
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
4.1 XML Schema Types
4.2 Building XML Schema Types
- A primitive data type cannot be expressed in terms of
any other data type.
- A derived type might be composed of other types.
- Data types are derived by restriction or
extension of existing data types.
4.3 XML Simple Types
<?xml version="1.0"?>
<xsd:simpleType xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" name="productCode">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{2}-\d{5}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="productCodeEx">
<xsd:restriction base="productCode">
<xsd:patter value"\d{2}-\d{5}(-[a-z]){0,1}"/>
</xsd:restriction>
</xsd:simpleType>
4.4 XML Complex Types
- We can define a schema for phone numbers that are just three
group of numbers.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:complexType name="telephoneNumber">
<xsd:sequence>
<xsd:element name="area">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="exchange">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="number">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{4}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<telephone xsi:type="abc:telephoneNumber">
<area>123</area>
<exchange>123</exchange>
<number>1234</number>
</telephone>
4.5 XML Complex Types by Extension
- If we wanted to add a country code to the previous
telephoneNumber type we would extend it.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:complexType name="telephoneNumberEx">
<xsd:complexContent>
<xsd:extension base="telephoneNumber">
<xsd:sequence>
<xsd:element name="countryCode">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<telephone xsi:type="abc:telephoneNumber">
<area>123</area>
<exchange>123</exchange>
<number>1234</number>
<contryCode>01</countryCode>
</telephone>
- Notice that the contryCode has to appear as the last
element, because we are deriving by extension.
- The types declared in the base class must appear before
those in the derived classes.
4.6 Netbeans XML Support
5 RDF
- Resource Description Framework [15].
- A model for representing data about resources on the web.
- Model is based on Subject, Verb, Object triples.
- A statement is an instantiated RDF triple.
- The Subject is a resource or statement, the Object can
either be a resource or a literal (string). This allows us to
express opinions about opinions.
5.1 RDF Picture
- RDF statements can be viewed as nodes and arcs
diagrams.
- The nodes (ovals) represent resources. The arcs represent
named properties. String literals are represented by
rectangles.
- Ora Lassila is the creator of the resource
http://www.w3.org/Home/Lassila.
- In RDF text this is represented by:
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://description.org/schema/">
<Description about="http://www.w3.org/Home/Lassila">
<s:Creator>Ora Lassila</s:Creator>
</Description>
</RDF>
5.2 RDF Abbreviated Syntax
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://description.org/schema/">
<Description about="http://www.w3.org/Home/Lassila">
<s:Creator>Ora Lassila</s:Creator>
</Description>
</RDF>
- Can be represented using a more abbreviated syntax as:
<?xml version="1.0"?>
<rdf:RDF "xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://description.org/schema/">
<rdf:Description about="http://www.w3.org/Home/Lassila"
s:Creator="Ora Lassila" />
</rdf:RDF>
<rdf:RDF>
<rdf:Description about="http://www.w3.org">
<s:Publisher>World Wide Web Consortium</s:Publisher>
<s:Title>W3C Home Page</s:Title>
<s:Date>1998-10-03T02:27</s:Date>
</rdf:Description>
</rdf:RDF>
<rdf:RDF>
<rdf:Description about="http://www.w3.org"
s:Publisher="World Wide Web Consortium"
s:Title="W3C Home Page"
s:Date="1998-10-03T02:27"/>
</rdf:RDF>
5.3 RDF Example
- The individual referred to by employee id 85740 is named
Ora Lassila and has the email address lassila@w3.org. The
resource http://www.w3.org/Home/Lassila was created by this
individual.
<rdf:RDF>
<rdf:Description about="http://www.w3.org/Home/Lassila">
<s:Creator rdf:resource="http://www.w3.org/staffId/85740"/>
</rdf:Description>
<rdf:Description about="http://www.w3.org/staffId/85740">
<v:Name>Ora Lassila</v:Name>
<v:Email>lassila@w3.org</v:Email>
</rdf:Description>
</rdf:RDF>
5.4 RDF Schema
- RDF Schema [16] is
a type system for RDF. It provides a way to define
domain-specific properties and classes of resources.
- The basic modeling primitives are class,
property and ConstraintProperty. They are all
Resources.
- RDF Schemas, when used, provide a standard (if limited)
model for describing facts about web resources.
5.5 RDF Schema Class Hierarchy
- Notice that there are subclass-of and type-of relationships.
5.6 RDF Schema Instance Example
- Is represented by the following RDF instance,
<rdf:RDF xml:lang="en"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Description ID="MotorVehicle">
<rdf:type resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf
rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
</rdf:Description>
<rdf:Description ID="PassengerVehicle">
<rdf:type resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdf:Description>
<rdf:Description ID="Truck">
<rdf:type resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdf:Description>
<rdf:Description ID="Van">
<rdf:type resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdf:Description>
<rdf:Description ID="MiniVan">
<rdf:type resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf rdf:resource="#Van"/>
<rdfs:subClassOf rdf:resource="#PassengerVehicle"/>
</rdf:Description>
</rdf:RDF>
5.7 FOAF
- Friend Of A
Friend [17] project, and RDF schema.
- My foaf RDF file (generate your own FOAF [18])
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/">
<foaf:Person>
<foaf:name>José M. Vidal</foaf:name>
<foaf:firstName>Jose</foaf:firstName>
<foaf:surname>Vidal</foaf:surname>
<foaf:mbox rdf:resource="mailto:jmvidal@gmail.com" />
<foaf:mbox_sha1sum>ee3b2ff0675e6349b2396f7671f95be3141692e9</foaf:mbox_sha1sum>
<foaf:nick >Jose</foaf:nick>
<foaf:workplacehomepage rdf:resource="http://www.cse.sc.edu" />
<foaf:homepage rdf:resource="http://jmvidal.cse.sc.edu" />
<foaf:phone rdf:resource="tel:1-803-733-1674"/>
<foaf:depiction
rdf:resource="http://jmvidal.cse.sc.edu/pictures/josevidal-small.jpg"/>
<foaf:publications>http://jmvidal.cse.sc.edu/papers/</foaf:publications>
<foaf:weblog rdf:resource="http://jmvidal.cse.sc.edu/mdl/" />
<foaf:weblog rdf:resource="http://www.multiagent.com" />
<foaf:knows>
<foaf:Person>
<foaf:name>Tim Finin</foaf:name>
<foaf:mbox_sha1sum>9da08e2b4dc670d9254ab4a4b4d61637fed3b18f</foaf:mbox_sha1sum>
<rdfs:seeAlso rdf:resource="http://umbc.edu/~finin/foaf.rdf"/>
</foaf:Person>
</foaf:knows>
</foaf:Person>
</rdf:RDF>
- Then add this to your
head
<link rel="meta" type="application/rdf+xml" title="FOAF" href="foaf.rdf" />
5.8 RDFa
- RDFa [19]
changes RDF syntax so it can be embeded into XHTML. Here is a
good tutorial [20],
part
2 [21].
- a is for attribute:
href
,
content
, rel
, rev
, and
datatype
, as well as the new about
,
role
and property
.
- At its simplest, use these attributes:
| Subject | Predicate | Object |
Object is a String | about | property | content or PCDATA |
Object is URI | about | rel | href |
for example:
<span about="http://www.snee.com/bobdc.blog/2006/12/generating_a_single_globally_u.html"
property="dc:title" content="Generating a Single Globally Unique ID"/>
<span about="http://www.snee.com/bobdc.blog/2006/12/generating_a_single_globally_u.html"
property="dc:title">Generating a Single Globally Unique ID</meta>
<span about="http://www.snee.com/bobdc.blog/2006/12/generating_a_single_globally_u.html"
rel="dc:subject" href="http://www.snee.com/bobdc.blog/neat_tricks/"/>
span
is popular, but you can use any element.
- You can add multiple POs to one S:
<img src="http://www.snee.com/img/myfile.jpg"
about="http://www.snee.com/img/myfile.jpg">
<span property="dc:subject" content="Niagra Falls"/>
<span property="dc:creator" content="Richard Mutt"/>
<span property="dc:format" content="img/jpeg"/>
</img>
- If there is no
about
the document itself is
the implied subject.
5.9 SPARQL
5.9.1 SPARQL: Optional
5.9.2 SPARQL: Union
5.9.3 SPARQL: Filter
5.10 Example: OpenCalais + Jena + NetBeans
- Here is a good tutorial [24]
on Jena [25]: an RDF
parser, SPARQL engine, and inference engine.
- OpenCalais [26] turns your English text into meaningfull RDF.
- DEMO: netbeans project.
- The program:
package edu.sc.cse;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.query.*;
import javax.xml.ws.WebServiceRef;
/**
*
* @author jmvidal
*/
public class Test extends HttpServlet {
@WebServiceRef(wsdlLocation = "http://api.opencalais.com/enlighten/?wsdl")
private Calais service;
static String apiKey = "jp35z8payqnh5zcpasnpvxmq"; static String paramsXML = "<c:params xmlns:c=\"http://s.opencalais.com/1/pred/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">" +
"<c:processingDirectives c:contentType=\"text/txt\" c:outputFormat=\"xml/rdf\">" +
"</c:processingDirectives>" +
"<c:userDirectives c:allowDistribution=\"true\" c:allowSearch=\"true\" c:externalID=\"17cabs901\" c:submitter=\"jmvidal\">" +
"</c:userDirectives>" +
"<c:externalMetadata></c:externalMetadata></c:params>";
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Model model = ModelFactory.createDefaultModel();
java.lang.String content = request.getParameter("text");
out.println("<html><head></head><title>OpenCalais Test</title>");
out.println("<body>");
out.println("<h1>OpenCalaisTest</h1>" +
"<form action=\"Test\" method=\"POST\">" +
"<textarea name=\"text\" rows=\"20\" cols=\"40\">");
if (content != null) { out.println(content);
}
out.println("</textarea><br/>" +
"<input type=\"submit\" value=\"Send\"/> <input type=\"reset\"/></form>");
try { edu.sc.cse.CalaisSoap port = service.getCalaisSoap();
if (content != null) {
java.lang.String result = port.enlighten(apiKey, content, paramsXML);
StringReader resultIn = new StringReader(result);
model.read(resultIn, "");
out.println("<!--");
model.write(out,"RDF/XML-ABBREV"); out.println("-->");
out.println("<h2>The Triples</h2>");
out.println("<table border=\"1\"><tr><th>Subject</th><th>Verb/Predicate</th><th>Object</th></tr>");
StmtIterator iter = model.listStatements();
while (iter.hasNext()) {
Statement stmt = iter.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); out.println("<tr><td>" + subject + "</td><td>" + predicate.toString() +
"</td><td>" + object + "</td></tr>\n");
}
out.println("</table>");
out.println("<h2>The People</h2><ol>");
StmtIterator iter2 = model.listStatements(
new SimpleSelector(null, RDF.type, (RDFNode) null) {
public boolean selects(Statement s) {
String object = s.getResource().toString();
return object.endsWith("Person");
}
});
if (iter2.hasNext()) {
while (iter2.hasNext()) {
Statement stmt = iter2.nextStatement();
Resource subject = stmt.getSubject();
iter = model.listStatements();
while (iter.hasNext()){
Statement stmt2 = iter.nextStatement();
Resource subject2 = stmt2.getSubject();
String predicate = stmt2.getPredicate().toString();
if (subject2.equals(subject) && predicate.endsWith("name")){ out.println("<li>" + stmt2.getObject() + "</li>");
}
}
}
} else {
out.println("No People found.");
}
out.println("</ol>");
out.println("<h2>The People (SPARQL query)</h2><ol>");
String queryString =
"PREFIX calaispred: <http://s.opencalais.com/1/pred/ [27]>" +
"PREFIX calaistype: <http://s.opencalais.com/1/type/em/e/ [28]>" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns# [29]>" +
"SELECT ?name " +
"WHERE {" +
" ?person rdf:type calaistype:Person . " +
" ?person calaispred:name ?name . " +
" }";
Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, model);
com.hp.hpl.jena.query.ResultSet results = qe.execSelect();
while (results.hasNext()){
out.println("<li>" + results.next() + "</li>");
}
qe.close();
out.println("</ol>");
}
} catch (Exception ex) {
out.println("ERROR: " + ex);
}
out.println("</body></html>");
} finally {
out.close();
}
}
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
}
6 OWL
- OWL is the
Web Ontology Language.
“An ontology is the attempt to formulate an exhaustive and
rigorous conceptual schema within a given domain, a typically
hierarchical data structure containing all the relevant entities and
their relationships and rules (theorems, regulations) within that
domain”. — Wikipedia:Ontology [30]
- It is a W3C Recommendation.
- Also, see the OWL Web Ontology
Language Overview [31]
- The standard for writing semantics..
6.1 DAML+OIL
- The pre-cursor to OWL. OWL copies it almost to the
letter.
- Darpa Agent Markup Language along with the Ontology
Interexchange Language extend RDF in order to create a
language for describing ontologies.
- There exist many ontologies [32]
written in DAML+OIL available for your use.
- You should always first try to reuse or extend existing
ontologies.
- There is a W3C Note on
DAML+OIL [33] which provides a good overview.
6.2 OWL Classes
- Start by defining classes which are subsets that contain all objects of that type.
<rdf:RDF
xmlns:owl ="http://www.w3.org/2002/07/owl#"
xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs ="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd ="http://www.w3.org/2001/XMLSchema#"
xmlns =""
>
<owl:Ontology rdf:about="">
<owl:versionInfo>$Id$</owl:versionInfo>
/
</owl:Ontology>
<owl:Class rdf:ID="Animal">
<rdfs:label>Animal</rdfs:label>
Not vegetable or mineral.
/
<owl:Class rdf:ID="Male">
<rdfs:label>Male</rdfs:label>
<rdfs:subClassOf rdf:resource="#Animal"/>
</owl:Class>
<owl:Class rdf:ID="Female">
<rdfs:label>Female</rdfs:label>
<rdfs:subClassOf rdf:resource="Animal"/>
<owl:disjointWith rdf:resource="Male"/>
</owl:Class>
</owl:Class>
</rdf:RDF>
- This is the definition of an Animal class, with a label of Animal and two subclasses: Male and Female.
6.3 OWL Properties
- An OWL property connects two items.
- They are datatype properties
(
owl:DatatypeProperty
) if they are relations
between instances of classes and RDF literals and XML Schema
datatypes.
- object properties
(
owl:ObjectProperty
)if they are relations between
instances of two classes.
<owl:ObjectProperty rdf:ID="hasParent">
<rdfs:domain rdf:resource="#Animal"/>
<rdfs:range rdf:resource="#Animal"/>
</owl:ObjectProperty>
- An Animal can have a parent which must be an Animal.
<owl:ObjectProperty rdf:ID="hasFather">
<rdfs:subPropertyOf rdf:resource="#hasParent"/>
<rdfs:range rdf:resource="#Male"/>
</owl:ObjectProperty>
- hasFather is a property that is a kind of hasParent property, i.e., x's father is
also x's parent.
6.4 OWL Property Restrictions
- We define a restricted class Person
<owl:Class rdf:ID="Person">
<rdfs:subClassOf rdf:resource="#Animal"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasParent"/>
<owl:toClass rdf:resource="#Person"/>
</owl:Restriction>
</rdfs:subClassOf>
- A Person is an Animal. The parent of a Person is also a Person.
<rdfs:subClassOf>
<owl:Restriction owl:cardinality="1">
<owl:onProperty rdf:resource="#hasFather"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#shoesize"/>
<owl:minCardinality>1</owl:minCardinality>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
- Any person must have exactly 1 father and at least one shoe size.
6.5 OWL Extends Other Ontologies
- You can extend an existing ontology by simply saying things about the terms in it.
<owl:Class rdf:about="#Animal">
Animals have exactly two parents, ie:
If x is an animal, then it has exactly 2 parents
(but it is NOT the case that anything that has 2
parents is an animal).
/
<rdfs:subClassOf>
<owl:Restriction owl:cardinality="2">
<owl:onProperty rdf:resource="#hasParent"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
- If the ontology is already published, you would instead use the full URL.
<owl:Class
rdf:about="http://www.sample.com/ontologies/zoo#Animal">
6.6 OWL Defines Individuals
- You can also define individual objects in a class.
<Person rdf:ID="Adam">
<rdfs:label>Adam</rdfs:label>
/
<age><xsd:integer rdf:value="13"/></age>
<shoesize><xsd:decimal rdf:value="9.5"/></shoesize>
</Person>
6.7 OWL Ontology
RDF Schema Features:
|
(In)Equality:
|
Property Characteristics:
|
Property Restrictions:
|
Restricted Cardinality:
|
Header Information:
|
Class Intersection:
|
Versioning:
|
Annotation Properties:
|
Datatypes
|
6.8 OWL Example
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns="http://www.xfront.com/owl/ontologies/camera/#"
xmlns:camera="http://www.xfront.com/owl/ontologies/camera/#"
xml:base="http://www.xfront.com/owl/ontologies/camera/">
<owl:Ontology rdf:about="">
Camera OWL Ontology
Author: Roger L. Costello
/
</owl:Ontology>
<owl:Class rdf:ID="Money">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
<owl:DatatypeProperty rdf:ID="currency">
<rdfs:domain rdf:resource="#Money"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:Class rdf:ID="Range">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
<owl:DatatypeProperty rdf:ID="min">
<rdfs:domain rdf:resource="#Range"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:ID="max">
<rdfs:domain rdf:resource="#Range"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:ID="units">
<rdfs:domain rdf:resource="#Range"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:Class rdf:ID="Window">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
<camera:Window rdf:ID="ThroughTheLens"/>
<camera:Window rdf:ID="WindowOnTopOfCamera"/>
<owl:Class rdf:ID="Viewer">
<owl:oneOf rdf:parseType="Collection">
<camera:Window rdf:about="#ThroughTheLens"/>
<camera:Window rdf:about="#WindowOnTopOfCamera"/>
</owl:oneOf>
</owl:Class>
<owl:Class rdf:ID="PurchaseableItem">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
<owl:ObjectProperty rdf:ID="cost">
<rdfs:domain rdf:resource="#PurchaseableItem"/>
<rdfs:range rdf:resource="#Money"/>
</owl:ObjectProperty>
<owl:Class rdf:ID="Body">
<rdfs:subClassOf rdf:resource="#PurchaseableItem"/>
</owl:Class>
<owl:Class rdf:ID="BodyWithNonAdjustableShutterSpeed">
<owl:intersectionOf rdf:parseType="Collection">
<owl:Class rdf:about="#Body"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#shutter-speed"/>
<owl:cardinality>0</owl:cardinality>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
<owl:Class rdf:ID="Lens">
<rdfs:subClassOf rdf:resource="#PurchaseableItem"/>
</owl:Class>
<owl:Class rdf:ID="Camera">
<rdfs:subClassOf rdf:resource="#PurchaseableItem"/>
</owl:Class>
<owl:Class rdf:ID="SLR">
<owl:intersectionOf rdf:parseType="Collection">
<owl:Class rdf:about="#Camera"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#viewFinder"/>
<owl:hasValue rdf:resource="#ThroughTheLens"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
<owl:Class rdf:ID="Large-Format">
<rdfs:subClassOf rdf:resource="#Camera"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#body"/>
<owl:allValuesFrom rdf:resource="#BodyWithNonAdjustableShutterSpeed"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
<owl:Class rdf:ID="Digital">
<rdfs:subClassOf rdf:resource="#Camera"/>
</owl:Class>
<owl:ObjectProperty rdf:ID="part"/>
<owl:ObjectProperty rdf:ID="lens">
<rdfs:subPropertyOf rdf:resource="#part"/>
<rdfs:domain rdf:resource="#Camera"/>
<rdfs:range rdf:resource="#Lens"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="body">
<rdfs:subPropertyOf rdf:resource="#part"/>
<rdfs:domain rdf:resource="#Camera"/>
<rdfs:range rdf:resource="#Body"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="viewFinder">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
<rdfs:domain rdf:resource="#Camera"/>
<rdfs:range rdf:resource="#Viewer"/>
</owl:ObjectProperty>
<owl:DatatypeProperty rdf:ID="size">
<rdfs:domain rdf:resource="#Lens"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:ID="aperture">
<rdfs:domain rdf:resource="#Lens"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:ObjectProperty rdf:ID="compatibleWith">
<rdfs:domain rdf:resource="#Lens"/>
<rdfs:range rdf:resource="#Body"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="shutter-speed">
<rdfs:domain rdf:resource="#Body"/>
<rdfs:range rdf:resource="#Range"/>
</owl:ObjectProperty>
<owl:DatatypeProperty rdf:ID="focal-length">
<owl:equivalentProperty rdf:resource="#size"/>
<rdfs:domain rdf:resource="#Lens"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:ID="f-stop">
<owl:equivalentProperty rdf:resource="#aperture"/>
<rdfs:domain rdf:resource="#Lens"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
</rdf:RDF>
6.9 From DAML+OIL to OWL
- The namespace was changed to
http://www.w3.org/2002/07/owl [36].
- Various updates to RDF and RDF Schema from the
RDF Core Working Group [37]
were incorporated,
including
- cyclic subclasses are now allowed
- multiple
rdfs:domain
and
rdfs:range
properties are handled as intersection
- RDF Semantics
- datatypes
- the
daml:List
construct used to represent closed collections
was largely incorporated into RDF
- rdf:parseType="Collection"
replaces
rdf:parseType="daml:collection"
rdf:List
, rdf:first
, rdf:rest
and rdf:nil
replace
daml:List
, daml:first
, daml:rest
,
and daml:nil
daml:item
is not supported.
- Qualified restrictions were removed from the language,
resulting in the removal of the following properties:
daml:cardinalityQ
daml:hasClassQ
daml:maxCardinalityQ
daml:minCardinalityQ
- Various properties and classes were renamed,
as shown in the following table:
DAML+OIL |
OWL |
daml:differentIndividualFrom |
owl:differentFrom |
daml:equivalentTo |
owl:sameAs |
daml:sameClassAs |
owl:equivalentClass |
daml:samePropertyAs |
owl:equivalentProperty |
daml:hasClass |
owl:someValuesFrom |
daml:toClass |
owl:allValuesFrom |
daml:UnambiguousProperty |
owl:InverseFunctionalProperty |
daml:UniqueProperty |
owl:FunctionalProperty |
-
owl:SymmetricProperty
was added.
- An
owl:DatatypeProperty
may be an
InverseFunctionalProperty
in OWL Full.
-
Synonyms for RDF and RDF Schema classes and properties were removed from the language,
resulting in the removal of:
daml:comment
daml:domain
daml:label
daml:isDefinedBy
daml:Literal
daml:Property
daml:range
daml:seeAlso
daml:subClassOf
daml:subPropertyOf
daml:type
daml:value
-
daml:disjointUnionOf
was removed from the language,
since it can be effected using
owl:unionOf
or
rdfs:subClassOf
and
owl:disjointWith
.
-
daml:equivalentTo
was renamed to
owl:sameAs
,
and is no longer a superproperty of
owl:equivalentClass
and
owl:equivalentProperty
,
-
The following properties and classes were added to support versioning:
- owl:backwardCompatibleWith
- owl:DeprecatedClass
- owl:DeprecatedProperty
- owl:incompatibleWith
- owl:priorVersion
- owl:AllDifferent and
owl:distinctMembers
were added to address the
Unique Names Assumption.
6.10 Three Sublanguages
- OWL Lite supports those users primarily needing a
classification hierarchy and simple constraints.
- OWL DL supports those users who want the maximum
expressiveness while retaining computational completeness (we
use Jess [40]).
- Named for Description Logics.
- Supports all constructs, but sometimes only under certain conditions.
- OWL Full is meant for users who want maximum
expressiveness and the syntactic freedom of RDF with no
computational guarantees.
- It is unlikely that any reasoning software will be
able to support complete reasoning for every feature of
OWL Full.
6.11 OWL Ontology Creation
6.12 The Future of OWL
- OWL has world-wide support.
- OWL adoption in industry is at its infancy.
- Tools exist that do inferencing over OWL, such as Jena.
7 Summary
- XML provides the syntax.
- RDF provides semantically simple but common (as in
"common-denominator") Subject Verb Action triples.
- OWL provides the power needed to describe useful
ontologies.
- Each one extends the previous one.
- Combine these representation languages with powerful
parsers, inference engines, and widespread use and we have an
amazingly powerful platform.
URLs
- Extensible Markup
Language (XML) 1.0, http://www.w3.org/TR/REC-xml/
- Tutorial: The
Semantic Web., http://jmvidal.cse.sc.edu/lib/klein01a.html
- The Semantic
Web: The Roles of XML and RDF., http://jmvidal.cse.sc.edu/library/w5063.pdf
- Finding
friends with XML and RDF, http://www.ibm.com/developerworks/xml/library/x-foaf.html
- Search
RDF Data with SPARQL, http://www.ibm.com/developerworks/xml/library/j-sparql/
- OWL Web Ontology
Language Overview, http://www.w3.org/TR/owl-features/
- W3C Recommendation
6, http://www.w3.org/TR/REC-xml
- over 10
years old, http://www.tbray.org/ongoing/When/200x/2008/02/10/XML-People
- XML
namespaces recommendation, http://www.w3.org/TR/REC-xml-names/
- RFC2396, http://www.ietf.org/rfc/rfc2396.txt
- XML Schema, http://www.w3.org/XML/Schema
- Lots of
support, http://xml.netbeans.org/
- tutorial , http://developers.sun.com/jsenterprise/nb_enterprise_pack/reference/techart/abe.html
- UBL Order, http://docs.oasis-open.org/ubl/cd-UBL-1.0/xsd/maindoc/UBL-Order-1.0.xsd
- Resource Description Framework, http://www.w3.org/RDF/
- RDF Schema, http://www.w3.org/TR/rdf-schema/
- Friend Of A
Friend, http://www.foaf-project.org/
- generate your own FOAF, http://www.ldodds.com/foaf/foaf-a-matic
- RDFa, http://www.w3.org/2006/07/SWD/RDFa/syntax
- tutorial, http://www.xml.com/pub/a/2007/02/14/introducing-rdfa.html
- part
2, http://www.xml.com/pub/a/2007/04/04/introducing-rdfa-part-two.html
- SPARQL, http://www.w3.org/TR/rdf-sparql-query/
- tutorials, http://jena.sourceforge.net/ARQ/Tutorial/index.html
- tutorial, http://www.ibm.com/developerworks/xml/library/j-sparql/
- Jena, http://jena.sourceforge.net
- OpenCalais, http://www.opencalais.com
- http://s.opencalais.com/1/pred/, http://s.opencalais.com/1/pred/
- http://s.opencalais.com/1/type/em/e/, http://s.opencalais.com/1/type/em/e/
- http://www.w3.org/1999/02/22-rdf-syntax-ns#, http://www.w3.org/1999/02/22-rdf-syntax-ns#
- wikipedia:Ontology_(computer_science), http://www.wikipedia.org/wiki/Ontology_(computer_science)
- OWL Web Ontology
Language Overview, http://www.w3.org/TR/owl-features/
- DAML sample
ontologies, http://www.daml.org/ontologies/
- W3C Note on
DAML+OIL, http://www.w3.org/TR/daml+oil-reference
- Appendix
D of the OWL reference, http://www.daml.org/2002/06/webont/owl-ref-proposed#appd
- DAML+OIL to OWL
converter, http://www.mindswap.org/2002/owl.html
- http://www.w3.org/2002/07/owl, http://www.w3.org/2002/07/owl
- RDF Core Working Group, http://www.w3.org/2001/sw/RDFCore/
- http://www.w3.org/2001/XMLSchema, http://www.w3.org/2001/XMLSchema
- http://www.w3.org/2000/10/XMLSchema, http://www.w3.org/2000/10/XMLSchema
- Jess, http://herzberg.ca.sandia.gov/jess/
- Protege, http://protege.stanford.edu
- Protege
Owl tutorial, http://www.co-ode.org/resources/tutorials/ProtegeOWLTutorial.pdf
This talk available at http://jmvidal.cse.sc.edu/talks/xmlrdfdaml/
Copyright © 2009 José M. Vidal
.
All rights reserved.
23 February 2008, 11:46AM